package com.paw.ruoyi.admin.core.config;

import com.paw.ruoyi.admin.core.intercepter.TraceInterceptor;
import com.paw.ruoyi.admin.core.intercepter.UserInfoInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Rubble
 * @date 2021/8/27
 **/
@Order(value = 1)
public class WebInterceptorConfiguration implements WebMvcConfigurer {

  @Autowired
  private StringRedisTemplate stringRedisTemplate;

  @Override
  public void addInterceptors (InterceptorRegistry registry) {
    registry.addInterceptor(new TraceInterceptor()).addPathPatterns("/api/**");
    registry.addInterceptor(new UserInfoInterceptor(stringRedisTemplate)).addPathPatterns("/api/**");
  }
}
